<%@ page language="java" contentType="text/html; charset=UTF8" pageEncoding="UTF8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.google.appengine.api.memcache.MemcacheService" %>
<%@ page import="com.google.appengine.api.memcache.MemcacheServiceFactory" %>
<%@ page import="com.google.appengine.api.memcache.ErrorHandlers" %>
<%@ page import="java.util.logging.Level" %>
<%@ page import="com.bun.ipmon.service.IpMonService" %>
<%@ page import="com.bun.ipmon.vo.Config" %>

<%
	String monitor = request.getParameter("monitor");
	String sender = request.getParameter("sender");
	String receiver = request.getParameter("receiver");
	String smsFrom = request.getParameter("smsFrom");
	String smsTo = request.getParameter("smsTo");
	String refresh = request.getParameter("refresh");
	String device = request.getParameter("device");
	
	IpMonService ipMonService = new IpMonService();
	
	if(monitor == null){
	}
	else {
		ipMonService.updateConfig(monitor, sender, receiver, smsFrom, smsTo, refresh, device);
	}
	Config existingConfig = ipMonService.getConfig();

%>

<form action="config.jsp" method="post">
 		<label style="font-size:22px;">Config</label>
 		<br/>
        <label for="code">Monitor:</label>  
        <input type="text" id="monitor" name="monitor" placeholder="monitor" value="<%=existingConfig.getMonitor()%>" required autofocus >
        <br/>
        <label for="code">Sender:</label>  
        <input type="text" id="sender" name="sender" placeholder="sender" value="<%=existingConfig.getSender()%>" required >
        <br/>
        <label for="code">Receiver:</label>  
        <input type="text" id="receiver" name="receiver" placeholder="receiver" value="<%=existingConfig.getReceiver()%>" required >
        <br/>
        <label for="code">SmsFrom:</label>  
        <input type="text" id="smsFrom" name="smsFrom" placeholder="smsFrom" value="1" required >
        <br/>
        <label for="code">SmsTo:</label>  
        <input type="text" id="smsTo" name="smsTo" placeholder="smsTo" value="2" required >
        <br/>
        <label for="refresh">Refresh:</label>  
        <input type="text" id="refresh" name="refresh" placeholder="refresh(5,10,30,60)" value="<%=existingConfig.getRefresh()%>" required >
        <br/>
        <label for="device">Device:</label>  
        <input type="text" id="device" name="device" placeholder="device(0=IP6P,1=IP6,2=both)" value="<%=existingConfig.getDevice()%>" required >
        <br/>
		<button type="submit">Update</button>  		
	 </form>  
